{% extends "admin/base_site.html" %}
{% load i18n future staticfiles %}

{% block extrahead %}
    <link rel="stylesheet" type="text/css" href="{% static "wladmin/css/login.css" %}">
    {{ block.super }}
    <style>
        #extra-login-fields {
            display: none;
        }
    </style>
{% endblock %}

{% block bodyclass %}login{% endblock %}
{% block header %}{% endblock %}
{% block content_title %}{% endblock %}
{% block breadcrumbs %}{% endblock %}

{% block content %}
    <h1 class="login_h1" style="margin-left: -45px;">
        {{ sitesettings.title }}管理后台<sup>V2016</sup>
    </h1>

    <div class="login_window">
        {% block login_header %}
            <div class="header">
                <div class="switch">
                    <a id="switch_login">快速登录</a>
                    <a id="switch_forget" href="{% url "password_reset" %}">忘记密码？</a>
                </div>
            </div>
        {% endblock %}

        {% block login_content %}
            {% if form.non_field_errors %}
                {% for error in form.non_field_errors %}
                    <p id="errornote">{{ error }}</p>
                {% endfor %}
            {% endif %}
            {% if no_site_permission %}
                <p id="errornote">{% trans "You don't have permission to access the admin for this site." %}</p>
            {% endif %}

            <form action="{{ app_path }}" method="post" id="login-form">
                {% csrf_token %}
                <div id="content-main">
                    <div class="form-row">
                        <label for="id_username" class="required">账号：</label>
                        <input type="text" required name="username" id="id_username"
                               value="{{ request.POST.username }}">
                    </div>
                    <div class="form-row">
                        <label for="id_password" class="required">密码：</label>
                        <input type="password" required name="password" id="id_password">
                        <input type="hidden" name="this_is_the_login_form" value="1"/>
                    </div>
                    <div class="form-row" id="extra-login-fields">
                        <label class="required">{% trans "Interface:" %}</label>
                        <input class="interface" type="radio" name="wenlincms_login_interface" id="interface_admin"
                               value="admin"{% if request.REQUEST.wenlincms_login_interface != "site" %}
                               checked{% endif %} />
                        <label class="interface" for="interface_admin">{% trans "Admin" %}</label>
                        <input class="interface" type="radio" name="wenlincms_login_interface" id="interface_site"
                               value="site"{% if request.REQUEST.wenlincms_login_interface == "site" %}
                               checked{% endif %} />
                        <label class="interface" for="interface_site">{% trans "Site" %}</label>
                    </div>
                </div>
                <div class="submit-row">
                    <input type="submit" value="登 录" class="button_blue"/>
                </div>
            </form>
        {% endblock %}
    </div>

    <div class="jianyi">*推荐使用ie10或以上版本ie浏览器或Chrome内核浏览器访问本站</div>

    <script type="text/javascript">
        jQuery(function ($) {
            $("#login-form").submit(function () {
                var un = $("#id_username").val().replace(/^\s\s*/, '').replace(/\s\s*$/, '');
                $("#id_username").val(un);
                if (un == "") {
                    return false;
                }
            });
        });
    </script>
{% endblock %}
